package com.wuliu.servlet;

import com.wuliu.dao.NewsClassDAO;
import com.wuliu.dao.impl.NewsClassDAOImpl;
import com.wuliu.model.NewsClass;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/admin/news_class")
public class AdminNewsClassServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        NewsClassDAO newsClassDAO = new NewsClassDAOImpl();
        List<NewsClass> newsClasses=newsClassDAO.findAll();
        req.setAttribute("newsClasses",newsClasses);
        req.getRequestDispatcher("/WEB-INF/view/admin/news_class.jsp").forward(req,resp);
    }
}